/**
 * API配置 - 统一管理API相关配置
 */

// 是否使用Mock数据（开发时可以切换）
export const USE_MOCK_DATA = import.meta.env.VITE_MOCK === "true" || false

// API端点配置
export const API_ENDPOINTS = {
  // 认证相关
  AUTH: {
    LOGIN: "auth/login",
    REFRESH: "auth/refresh",
    LOGOUT: "auth/logout",
    CURRENT_USER: "auth/me",
    CHECK_STATUS: "auth/check",
    CAPTCHA: "auth/captcha",
    CAPTCHA_REFRESH: "auth/captcha/refresh",
    CAPTCHA_VALIDATE: "auth/captcha/validate"
  },

  // 数据库管理
  DATABASE: {
    TEST_CONNECTION: "database/testConnection",
    GET_TABLES: "database/tables",
    GET_TABLE_DETAIL: "database/tableDetail",
    IMPORT_TABLES: "database/importTables",
    GET_IMPORTED_TABLES: "database/importedTables",
    DELETE_IMPORTED_TABLE: "database/importedTables",
    UPDATE_TABLE: "database/importedTables",
    SYNC_TABLE: "database/syncTable",
    GET_TABLE_RELATIONS: "database/tableRelations",
    GENERATE_DDL: "database/generateDDL"
  },

  // API端点管理
  API_ENDPOINT: {
    LIST: "apiEndpoint/list",
    DETAIL: "apiEndpoint",
    CREATE: "apiEndpoint",
    UPDATE: "apiEndpoint",
    DELETE: "apiEndpoint",
    BATCH_DELETE: "apiEndpoint/batch",
    TOGGLE: "apiEndpoint/toggle",
    GENERATE_CRUD: "apiEndpoint/generateCrud",
    PREVIEW: "apiEndpoint/preview"
  },

  // 代码生成
  CODE_GENERATION: {
    GENERATE: "codeGeneration/generate",
    PROGRESS: "codeGeneration/progress",
    HISTORY: "codeGeneration/history",
    DOWNLOAD: "codeGeneration/download",
    DELETE: "codeGeneration/project",
    REGENERATE: "codeGeneration/regenerate",
    PREVIEW: "codeGeneration/preview",
    STRUCTURE: "codeGeneration/structure",
    CANCEL: "codeGeneration/cancel"
  },

  // 模板管理
  TEMPLATE: {
    LIST: "template/list",
    DETAIL: "template",
    CREATE: "template",
    UPDATE: "template",
    DELETE: "template",
    BATCH_DELETE: "template/batch",
    TOGGLE: "template/toggle",
    STATS: "template/stats",
    DOWNLOAD: "template/download",
    INCREMENT_DOWNLOAD: "template/download/increment",
    RATE: "template/rate",
    RECOMMENDED: "template/recommended"
  }
}

// 响应状态码
export const RESPONSE_CODES = {
  SUCCESS: 0,
  UNAUTHORIZED: 401,
  FORBIDDEN: 403,
  NOT_FOUND: 404,
  SERVER_ERROR: 500
}

// 分页默认配置
export const PAGINATION_CONFIG = {
  DEFAULT_PAGE: 1,
  DEFAULT_SIZE: 10,
  SIZE_OPTIONS: [10, 20, 50, 100]
}

// 文件上传配置
export const UPLOAD_CONFIG = {
  MAX_FILE_SIZE: 10 * 1024 * 1024, // 10MB
  ALLOWED_TYPES: [".zip", ".rar", ".tar.gz"],
  UPLOAD_URL: "file/upload"
}

// WebSocket配置（如果需要实时进度推送）
export const WEBSOCKET_CONFIG = {
  ENDPOINT: "/ws",
  RECONNECT_INTERVAL: 3000,
  MAX_RECONNECT_ATTEMPTS: 5
}
